package environment {
	import org.flixel.FlxSprite;

	/**
	 * @author NilsIH
	 */
	public class EndlessElement extends NiloGroup {
		
		private var _elements:Array;
		private var gfxWidth:Number;
		protected var totalWidth:Number;
		public function EndlessElement(Y:Number, Width:Number, GFXWidth:Number, GFX:Class){
			super(GFXWidth, Y);
			gfxWidth = GFXWidth;
			var spriteAmt:uint = Math.ceil(Width / GFXWidth) + 1;
			var x_inc:Number = 0;
			_elements = [];
			for (var i:uint = 0; i < spriteAmt; i++){
				var sprite:FlxSprite = new FlxSprite(x_inc, 0, GFX);
				_elements.push(sprite);
				add(sprite);
				x_inc += GFXWidth;
			}
			
			totalWidth = x_inc;
		}
		
		override public function update():void{
			if (x >= 0){
				x -= gfxWidth;
			}
			else if(x <= -gfxWidth){
				x += gfxWidth;
			}
			super.update();
		}
		
		public function move(speed:Number):void{
			velocity.x = speed;
			
		}
	}
}
